package org.sixtynine.stock.service.impl;

import java.util.Date;
import java.util.List;

import org.sixtynine.stock.dao.AnnualSectorDataDao;
import org.sixtynine.stock.dto.GridPramDTO;
import org.sixtynine.stock.dto.Page;
import org.sixtynine.stock.entity.AnnualSectorData;
import org.sixtynine.stock.service.AnnualSectorDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Thilan
 * 
 */

@Service
public class AnnualSectorDataServiceImpl implements AnnualSectorDataService {

	@Autowired
	private AnnualSectorDataDao annualSectorDataDao;

	@Override
	public AnnualSectorData findById(int id) {
		return annualSectorDataDao.findById(id);
	}

	@Override
	@Transactional(readOnly = false)
	public void saveAnnualSectorData(AnnualSectorData annualSectorData) {
		annualSectorDataDao.saveAnnualSectorData(annualSectorData);
	}

	@Override
	@Transactional(readOnly = false)
	public void deleteAnnualSectorData(int id) {
		AnnualSectorData annualSectorData = annualSectorDataDao.findById(id);
		if (annualSectorData != null) {
			annualSectorDataDao.delete(annualSectorData);
		}
	}

	@Override
	public List<AnnualSectorData> findAnnualSectorData(int id) {
		return annualSectorDataDao.findAnnualSectorData(id);
	}

	@Override
	public List<AnnualSectorData> searchAnnualSectorData(int sectorId,
			Date fromDate, Date toDate, String orderBy, String orderByName) {
		return annualSectorDataDao.searchAnnualSectorData(sectorId, fromDate,
				toDate, orderBy, orderByName);
	}

	@Override
	public Page<AnnualSectorData> searchAnnualSectorData(int sectorId,
			Date fromDate, Date toDate, String orderBy, String orderByName,
			GridPramDTO gridPramDTO) {
		return annualSectorDataDao.searchAnnualSectorData(sectorId, fromDate,
				toDate, orderBy, orderByName, gridPramDTO);
	}

	@Override
	public void deleteAnnualSectorData(int sectorId, Date fromDate, Date toDate) {
		annualSectorDataDao.deleteAnnualSectorData(sectorId, fromDate, toDate);
	}

}
